#include <stdio.h>

int main()
{
    int area = 0; /* area of the shape (dropping any half-square) */
    int num_rows, num_cols, i, j;

    scanf("%d %d", &num_rows, &num_cols);
    for (i = 0; i < num_rows; i++)
    {
        int d = -1; /* -1 if current area is outside the shape; 1 if inside */
        char line[200];
        scanf("%s", line);
        for (j = 0; j < num_cols; j++)
        {
            if (line[j] != '.')
            {
                area += d * j;
                d = -d;
            }
        }
    }
    printf("%d\n", area);
    return 0;
}
